package com.swt.controller.S_controller;

import com.alibaba.fastjson.JSON;
import com.swt.domain.*;
import com.swt.service.S_service.GetVipCardService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.smartcardio.Card;
import java.util.List;
import java.util.Map;

@Controller
public class GetVipCardController {
    /*获取店铺vip卡的controller*/
    /*注入service*/
    @Resource(name = "S_getVipCardService")
    private GetVipCardService getVipCardService;
    @RequestMapping("/S_getVipCardByClubId")
    @ResponseBody
    public String getVipCardByClubId(int clubId){
        List<Member> list = getVipCardService.getVipCardByClubId(clubId);
        String list1=JSON.toJSONString(list);
        return list1;
    }

    /*根据id获取店铺信息*/
    @RequestMapping("/S_getClubshop")
    @ResponseBody
    public String getClubById(int clubId){
        /*调用service*/
        Shop shop = getVipCardService.getClubById(clubId);
        String shop1=JSON.toJSONString(shop);
        return shop1;
    }
    /*根据课程id找到该课程可用的会员卡*/
    @RequestMapping("/S_getVipCardByCourseId")
    @ResponseBody
    public String getVipCardByCourseId(int courseid,HttpServletRequest request){
        User user = (User)request.getSession().getAttribute("USER_SESSION_KEY");
        int userid=user.getUserId();
        /*调用service*/
        Map<String, List<Vipcard>> map = getVipCardService.getVipCardByCourseId(courseid, userid);
        String map1=JSON.toJSONString(map);
        return map1;
    }
}
